﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using The_Chronicles_of_Asku.Areas.Tomb_Floors._1_10.ResourceFile;
using The_Chronicles_of_Asku.Characters;

namespace The_Chronicles_of_Asku.Areas.Tomb_Floors._1_10
{
    class FloorThree
    {
        Battle battle = new Battle();
        Skeleton skel = new Skeleton();
        Necromancer necro = new Necromancer();
        Undead zombie = new Undead();
        SetMobLevels setLevel = new SetMobLevels();
        Hero myHero = new Hero();
        Villager villager = new Villager();
        public bool complete = false;

        public void theFloor(Hero myHero, Mob mob)
        {
            setLevel.setMobLevelNine(skel, necro, zombie, villager);

            Console.WriteLine(FloorThreeText.Entrance);
            Console.ReadKey();
            Console.Clear();

            NecromancerFight(myHero, necro);
            NecromancerFight(myHero, necro);

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorThreeText.FirstMove);
                Console.WriteLine();
                string letterAnswer = Console.ReadLine();

                if (letterAnswer == "1")
                {
                    Console.WriteLine(FloorThreeText.YesToLetter);

                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);

                    if (myHero.isAlive == true)
                    {
                        Console.WriteLine(FloorThreeText.LetterYesAfterUndead);
                        Console.ReadKey();
                        Console.Clear();
                    }
                }

                else
                {
                    Console.WriteLine(FloorThreeText.NoToLetter);
                    Console.ReadKey();
                    Console.Clear();
                }
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorThreeText.SecondMove);
                Console.WriteLine();

                SkeletonFight(myHero, skel);
                SkeletonFight(myHero, skel);
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorThreeText.FirstDecision);
                string turnAnswer = Console.ReadLine();

                if (turnAnswer == "1")
                {
                    Console.WriteLine(FloorThreeText.FirstLeft);
                    Console.WriteLine();

                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);
                    UndeadFight(myHero, zombie);

                    if (myHero.isAlive == true)
                    {
                        Console.WriteLine(FloorThreeText.FirstLeftTwo);
                    }
                }

                else
                {
                    Console.WriteLine(FloorThreeText.FirstRight);
                    string trapDoor = Console.ReadLine();

                    if (trapDoor == "1")
                    {
                        Console.WriteLine(FloorThreeText.TrapDoor);

                        VillagerFight(myHero, villager);
                        VillagerFight(myHero, villager);
                        VillagerFight(myHero, villager);
                        VillagerFight(myHero, villager);
                        VillagerFight(myHero, villager);
                        VillagerFight(myHero, villager);
                        VillagerFight(myHero, villager);
                        VillagerFight(myHero, villager);
                        VillagerFight(myHero, villager);

                        if (myHero.isAlive == true)
                        {
                            Console.WriteLine(FloorThreeText.TrapDoorTwo);
                            Console.Clear();
                            Console.WriteLine(FloorThreeText.FirstRightTwoWithCellar);

                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                        }
                    }

                    else
                    {
                        Console.WriteLine(FloorThreeText.FirstRightTwoWithoutCellar);
                        
                        NecromancerFight(myHero, necro);
                        NecromancerFight(myHero, necro);
                        NecromancerFight(myHero, necro);
                        NecromancerFight(myHero, necro);
                    }

                    if (myHero.isAlive == true)
                    {
                        Console.WriteLine(FloorThreeText.FirstRightFinal);
                        Console.ReadKey();
                        Console.Clear();
                        complete = true;
                    }
                }
            }

         if (myHero.isAlive == false)
                {
                    Console.WriteLine(FloorThreeText.Dead);
                    Console.ReadKey();
                    Console.Clear();

                    myHero.isAlive = true;
                }
        }

        private void UndeadFight(Hero myHero, Undead zombie)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, zombie);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            zombie.ResetStats(zombie);

            Console.Clear();
        }

        private void SkeletonFight(Hero myHero, Skeleton skel)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, skel);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            skel.ResetStats(skel);

            Console.Clear();
        }

        private void NecromancerFight(Hero myHero, Necromancer necro)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, necro);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            necro.ResetStats(necro);

            Console.Clear();
        }

        private void VillagerFight(Hero myHero, Villager villager)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, villager);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            villager.ResetStats(villager);

            Console.Clear();
        }
    }
}
